//
//  RegistrationRecordsCell.swift
//  EyeVisionForPatients
//
//  Created by PMC on 2020/4/20.
//  Copyright © 2020 QDSG. All rights reserved.
//

import UIKit

protocol RegistrationRecordsCellDelegate: NSObjectProtocol {
    func registrationRecordsCellCancelBtnAction(indexPath: IndexPath)
}

class RegistrationRecordsCell: UITableViewCell {
    
    var indexPath = IndexPath(row: 0, section: 0)
    weak var delegate: RegistrationRecordsCellDelegate?
    
    func updateData(vm: RegistRowViewModel, indexPath: IndexPath) {
        self.indexPath = indexPath
        doctorNameLabel.text = vm.docName
        doctorNameLabel.textColor = vm.status.doctorTextColor
        docDepartLabel.text = " \(vm.deptName) "
        docDepartLabel.textColor = vm.status.deptTextColor
        docDepartLabel.backgroundColor = vm.status.deptBgColor
        statusLabel.text = vm.status.text
        statusLabel.textColor = vm.status.statusTextColor
        patientNameLabel.text = "就诊人: \(vm.patientName)"
        patientNameLabel.textColor = vm.status.otherColor
        timeLabel.text = "就诊日期: \(vm.scheduleDate)"
        timeLabel.textColor = vm.status.otherColor
        cancelBtn.isHidden = vm.status != .sucess
    }
    
    @IBOutlet weak var doctorNameLabel: UILabel!
    @IBOutlet weak var docDepartLabel: UILabel! {
        didSet {
            docDepartLabel.layer.cornerRadius = docDepartLabel.height / 2.0
            docDepartLabel.layer.masksToBounds = true
        }
    }
    @IBOutlet weak var statusLabel: UILabel!
    @IBOutlet weak var patientNameLabel: UILabel!
    @IBOutlet weak var timeLabel: UILabel!
    @IBOutlet weak var cancelBtn: UIButton!
    @IBAction func cancelBtnAction(_ sender: Any) {
        delegate?.registrationRecordsCellCancelBtnAction(indexPath: indexPath)
    }
    
    

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
